package patrol.mobile.com.mobilepatrol.activity.security.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.dl7.recycler.adapter.BaseQuickAdapter;
import com.dl7.recycler.adapter.BaseViewHolder;

import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.security.emergency.EmergencySaveCheckAddActivity;
import patrol.mobile.com.mobilepatrol.activity.security.emergency.EmergencyZG2Activity;
import patrol.mobile.com.mobilepatrol.bean.SaveCheckLeaderCopyListBean;

/**
 * Created by K on 2018/9/11.
 * des:
 */
public class EmergencySaveCheck1ListAdapter extends BaseQuickAdapter<SaveCheckLeaderCopyListBean> {
    public EmergencySaveCheck1ListAdapter(Context context) {
        super(context);
    }

    @Override
    protected int attachLayoutRes() {
        return R.layout.item_emergency_save_check1_list;
    }

    @Override
    protected void convert(BaseViewHolder holder, final SaveCheckLeaderCopyListBean item) {
        holder.setText(R.id.tv_num, (holder.getLayoutPosition() + 1) + "");
        holder.setText(R.id.tv_orgName, item.getOrgName());
        holder.setText(R.id.tv_problemName, item.getProblemName());
        holder.getView(R.id.tv_level).setVisibility(View.VISIBLE);
        if (item.getProblemLevel().equals("0")) {
            holder.setText(R.id.tv_level, "无隐患");
        } else if (item.getProblemLevel().equals("1")) {
            holder.setText(R.id.tv_problemLevel, "一般隐患");
        } else {
            holder.setText(R.id.tv_problemLevel, "重大隐患");
        }

        holder.setText(R.id.tv_problemLevel, "检查组长:" + item.getCheckLeader());
//        }
        switch (item.getLargeType()) {
            case "1":
                holder.setText(R.id.tv_yesRectify, "检查大类：安全生产");
                break;
            case "2":
                holder.setText(R.id.tv_yesRectify, "检查大类：综治维稳");
                break;
            case "3":
                holder.setText(R.id.tv_yesRectify, "检查大类：平安建设");
                break;
        }

//        holder.setText(R.id.tv_yesRectify, item.getYesRectify().equals("0") ? "未整改" : "已整改");
        holder.setText(R.id.tv_checkDate, item.getUpdateDate());
//        holder.setText(R.id.tv_auditName, TextUtils.isEmpty(item.getAuditName()) ? "--" : item.getAuditName());

        holder.setText(R.id.tv_auditName, item.getYesRectify().equals("0") ? "未整改" : "已整改");
        holder.setText(R.id.tv_problemName, "整改人:" + item.getRectifyBy());


        holder.getView(R.id.rl_root).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mContext, EmergencyZG2Activity.class);
                intent.putExtra("id", item.getId());
                intent.putExtra("auditFlag", item.getAuditFlag());
                intent.putExtra("auditName", item.getAuditName());
                mContext.startActivity(intent);
            }
        });

    }
}
